import { graphql, buildSchema } from 'graphql';

// 构建 schema，使用 GraphQL schema 语言
var schema = buildSchema(`
    type Query {
        hello: String
    }
`);

// rootValue 为每个 API 端点提供解析器函数
var rootValue = {
    hello: () => {
        return 'Hello world!';
    },
};

graphql({
    schema,
    source: '{ hello }',
    rootValue,
}).then((response) => {
    console.log(response, JSON.stringify(response));
});
